package com.huawei.appgallery.appcomment.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.huawei.appgallery.appcomment.impl.bean.AppInfoBean;
import com.huawei.appgallery.appcomment.impl.bean.GetCommentResBean.AppCommentInfo;
import com.huawei.appgallery.appcomment.ui.view.CommentItemView;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSSelector;
import com.huawei.appgallery.foundation.ui.css.CSSView;
import o.bdm;
import o.bds.c;
import o.bek;
import o.cij;

public class AppCommentListAdapter extends BaseAdapter implements c, cij {
    private AppInfoBean commentBean;
    private Context context = null;
    private bdm provider = null;

    public AppCommentListAdapter(Context context, bdm o_bdm) {
        this.context = context;
        this.provider = o_bdm;
        this.provider.ˏ((c) this);
    }

    public void setDetailCommentBean(AppInfoBean appInfoBean) {
        this.commentBean = appInfoBean;
    }

    public boolean hasMore() {
        if (this.provider != null) {
            return this.provider.ʼ();
        }
        return false;
    }

    public void onDataUpdated() {
        notifyDataSetChanged();
    }

    public int getItemViewType(int i) {
        AppCommentInfo item = getItem(i);
        if (item != null) {
            return item.ˉ();
        }
        return 5;
    }

    public int getCount() {
        return this.provider.ˏ();
    }

    public int getViewTypeCount() {
        return 5;
    }

    public AppCommentInfo getItem(int i) {
        return this.provider.ˏ(i);
    }

    public long getItemId(int i) {
        return (long) i;
    }

    public View getView(int i, View view, ViewGroup viewGroup) {
        AppCommentInfo item = getItem(i);
        if (item == null) {
            return null;
        }
        int ˉ = item.ˉ();
        if (view == null) {
            view = createItemView(ˉ);
        }
        bek o_bek = (bek) view.getTag();
        boolean z = false;
        if (i == getCount() - 1) {
            z = true;
        }
        if (o_bek == null) {
            return view;
        }
        o_bek.ˎ(item, view, this.commentBean, z);
        return view;
    }

    private View createItemView(int i) {
        View commentItemView;
        bek o_bek = new bek();
        switch (i) {
            case 3:
                commentItemView = new CommentItemView(this.context, false);
                break;
            default:
                commentItemView = new View(this.context);
                commentItemView.setVisibility(8);
                break;
        }
        if (o_bek.ˋ(commentItemView, i)) {
            commentItemView.setTag(o_bek);
        }
        cssRender(commentItemView);
        return commentItemView;
    }

    public void cssRender(View view) {
        if (this.provider.ॱˋ() != null) {
            CSSRule rule = new CSSSelector(this.provider.ˋ()).getRule(this.provider.ॱˋ().getRootRule());
            if (rule != null) {
                CSSView.wrap(view, rule).render();
            }
        }
    }
}
